# 导包
# import requests
#
# # 先调用获取验证码接口
# response_verify = requests.get(url="http://tpshop-test.itheima.net/index.php?m=Home&c=User&a=verify")
# # 获取cookie(令牌)
# cookie = response_verify.cookies
# # 调用登录接口
# response_login = requests.post(url="http://tpshop-test.itheima.net/index.php?m=Home&c=User&a=do_login",
#                                headers={"Content-Type": "application/x-www-form-urlencoded"},
#                                data="username=13800138006&password=123456&verify_code=8888",
#                                cookies=cookie)
# # 打印登录的结果
# print("登录的结果为: ", response_login.json())

# 导包
import requests

# 调用获取验证码接口
response_verify = requests.get(url="http://tpshop-test.itheima.net/index.php?m=Home&c=User&a=verify")
# 获取cookie(令牌)
cookie = response_verify.cookies
# 调用登录接口
response_login = requests.post(url="http://tpshop-test.itheima.net/index.php?m=Home&c=User&a=do_login",
                               headers={"Content-Type": "application/x-www-form-urlencoded"},
                               data="username=13800138006&password=123456&verify_code=8888",
                               cookies=cookie)
# 打印登陆结果
print("登陆的结果为:", response_login.json())
